package com.etb.wisdom.eframe.dict.action;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import com.etb.web.action.ETBAction;
import com.etb.web.eui.utils.EuiUtil;
import com.etb.wisdom.eframe.dict.external.EtbDictService;
import com.etb.wisdom.eframe.model.EtbDictinfo;

@Action("dict")
@Namespace("/eframe/dict")
public class EtbDictAction extends ETBAction<EtbDictinfo> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4963648261510552052L;
	
	@Autowired
	private EtbDictService dictService;
	
	public void type(String typecode) {
		
	}

	public void getTypes(String typecode) {
		
	}

	public void getInfo(String infocode) {
		// TODO Auto-generated method stub
		
	}

	public void infos() {
		String typecode = request.getParameter("typecode");
		if(StringUtils.isNotBlank(typecode)) {
			List<EtbDictinfo> infos = dictService.getInfos(typecode);
			EuiUtil.toJson(infos);
		}
	}

	public void subinfos() {
		String typecode = request.getParameter("typecode");
		String infocode = request.getParameter("infocode");
		if(StringUtils.isNotBlank(typecode) && StringUtils.isNotBlank(infocode)) {
			List<EtbDictinfo> infos = dictService.getInfos(typecode);
			EuiUtil.toJson(infos);
		}
	}

}